/*
 * Created: Author: Ivan Lampert / Date: Jan 25, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-05-15 00:29:31 +0000 (Fri, 15 May 2015) $
 */
package com.cpm.wrapper;

import com.cpm.context.SystemLogger;
import com.cpm.wrapper.exception.SystemException;
import java.io.Serializable;
import java.util.Arrays;

public final class SolidObjects implements Serializable {

    private static final long serialVersionUID = -1359945456649886167L;

    private SolidObjects() {
    }

    public static final <T> T notNull(T value) {
        final String exceptionMessage = "Objeto nulo inesperado encontrado!";
        if (value == null) {
            throw new SystemException(exceptionMessage);
        }

        return value;
    }

    public static final <T> void notNullValues(T... value) {
        notNull(value);
        Arrays.asList(value).forEach(object -> {
            notNull(object);
        });
    }

    public final static <T> T createInstanceOf(Class<T> instantiableClass) {
        notNull(instantiableClass);

        try {
            return instantiableClass.newInstance();
        }
        catch (InstantiationException | IllegalAccessException e) {
            SystemLogger.logException(e);
        }

        return null;
    }

}
